<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateProductLogsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('product_logs', function (Blueprint $table) {
            $table->id()->comment('商品统计表');
            $table->integer('pay_user_id')->index()->comment('支付用户ID');
            $table->integer('product_id')->index()->comment('商品ID');
            $table->integer('user_id')->index()->comment('用户ID');
            $table->tinyInteger('visit_num')->comment('浏览量');
            $table->tinyInteger('visitor_num')->comment('访客量');
            $table->integer('cart_num')->comment('加入购物车数量');
            $table->integer('order_num')->comment('下单数量');
            $table->integer('pay_num')->comment('支付数量');
            $table->decimal('pay_price',8,2)->comment('支付金额(分)');
            $table->decimal('cost_price',8,2)->comment('商品成本价(分)');
            $table->integer('refund_num')->comment('退款数量');
            $table->decimal('refund_price',8,2)->comment('退款金额(分)');
            $table->integer('collect_num')->comment('收藏数量');
            $table->decimal('margin')->comment('毛利率');
            $table->decimal('payment')->comment('支付转换率');
            $table->string('type' ,20)->comment('活动类型 noActivity : 普通商品，seckill : 秒杀，bargain : 砍价，combination : 拼团');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('product_logs');
    }
}
